<template>
	<view class="bg-white u-m-t-16 border-t u-flex u-row-between">
		<view v-for="(item,index) in fastList" :key="item.name">
			<view @click="handleFast(item)" class="bg-white fast-item">
				<u-image width="26px" height="26px" :src="item.disabled?item.icon_no:item.icon">
				</u-image>
				<text :class="['u-font-12 u-m-t-12',item.disabled?'color-80':'']">{{item.name}}</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: ['info'],
		name: "contactWay",
		data() {
			return {
				fastList: []
			};
		},
		mounted() {
			this.fastList = [{
				icon: require('@/static/index/phone.png'),
				icon_no: require('@/static/index/phone_no.png'),
				name: '拔打电话',
				field: 'mobile', // 通过后端透传该字段，以下雷同
				disabled: !this.info.mobile
			}, {
				icon: require('@/static/index/wechat.png'),
				icon_no: require('@/static/index/wechat_no.png'),
				name: '复制微信',
				field: 'wechat',
				disabled: !this.info.wechat
			}, {
				icon: require('@/static/index/qq.png'),
				icon_no: require('@/static/index/qq_no.png'),
				name: '复制QQ号',
				field: 'qq',
				disabled: !this.info.qq
			}, {
				icon: require('@/static/index/code.png'),
				icon_no: require('@/static/index/code_no.png'),
				name: '微信二维码',
				field: 'wechat_qrcode',
				disabled: !this.info.wechat_qrcode
			}]
		},
		methods: {
			handleFast(item) {
				if (item.disabled) return;
				if (item.field === 'mobile') {
					uni.makePhoneCall({
						phoneNumber: this.info[item.field]
					});
				} else if (item.field === 'wechat_qrcode') {
					uni.previewImage({
						current: this.info[item.field],
						urls: [this.info[item.field]]
					})
				} else {
					uni.setClipboardData({
						data: this.info[item.field],
						success: () => {}
					});
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.fast-item {
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		padding: 10px 0;
	}
</style>
